{%extends "base.njk"%}

{% block content %}
  <div class="row">
    <div class="col-md-3"></div>
    <div class="col-md-6">
      <form id="registerform">
        <div class="form-group">
          <label for="username">账号</label>
          <input type="text" class="form-control" id="username" name="username" placeholder="请输入账号">
        </div>
        <div class="form-group">
          <label for="password">密码</label>
          <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
        </div>
        <button id="regBtn" type="button" class="btn btn-default">登录</button>
      </form>

    </div>
    <div class="col-md-3"></div>
  </div>
  <script>
    $('#regBtn').click(function(){
      var data = new FormData(document.getElementById("registerform"));
      $.ajax({
        cache: false,
        type: "POST",
        url:'/login',
        data:data,
        processData:false,
        contentType:false,
        error: function(request) {
          alert("error");
        },
        success: function(data) {
          alert(data.msg);
        }
      });
    })
  </script>
{% endblock %}